package com.liesheng.haylou.db.entity;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Transient;

/**
 * Date:2019/12/4
 * <p>
 * Author:wuzhiguang
 * <p>
 * Description:
 * 已绑定设备
 */
@Entity
public class BoundedDevice implements Serializable {
    private static final long serialVersionUID = 42L;
    @Id
    private String address;
    private String name;
    /**
     * 暂定 0-蓝牙耳机
     */
    private int type;

    private double latitude;//纬度
    private double longitude;//经度

    private String broadcast_count = "00";//广播计数,当本地记录的数值与广播包中的数值不等时则需要弹窗

    @Transient
    private int[] batteries;//盒子-左耳机-右耳机  电量
    @Transient
    private int[] charging;//盒子-左耳机-右耳机  是否在充电,1为充电
    @Transient
    private boolean hasScaned = false;//设备是否被扫描到了 1-是 0-否

    @Convert(columnType = String.class, converter = StringConverter.class)
    private List<String> locations; //上次使用位置

    @Generated(hash = 1851806860)
    public BoundedDevice(String address, String name, int type, double latitude,
                         double longitude, String broadcast_count, List<String> locations) {
        this.address = address;
        this.name = name;
        this.type = type;
        this.latitude = latitude;
        this.longitude = longitude;
        this.broadcast_count = broadcast_count;
        this.locations = locations;
    }

    @Generated(hash = 951367829)
    public BoundedDevice() {
    }

    public String getAddress() {
        return this.address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return this.type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public List<String> getLocations() {
        return this.locations;
    }

    public void setLocations(List<String> locations) {
        this.locations = locations;
    }

    public void addLocateion(String location) {
        if (locations == null) {
            locations = new ArrayList<>();
        }
        locations.add(0, location);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BoundedDevice that = (BoundedDevice) o;
        return address.equals(that.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(address);
    }

    public String getBroadcast_count() {
        return this.broadcast_count;
    }

    public void setBroadcast_count(String broadcast_count) {
        this.broadcast_count = broadcast_count;
    }

    public int[] getBatteries() {
        return batteries;
    }

    public void setBatteries(int[] batteries) {
        this.batteries = batteries;
    }

    public int[] getCharging() {
        return charging;
    }

    public void setCharging(int[] charging) {
        this.charging = charging;
    }

    public boolean isHasScaned() {
        return hasScaned;
    }

    public void setHasScaned(boolean hasScaned) {
        this.hasScaned = hasScaned;
    }

    public double getLatitude() {
        return this.latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return this.longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

}
